<template>
  <div class="panel">
    <!-- 编辑操作 -->
    <div class="left" v-if="isActive == 1">
      <!-- 场景灯光========== -->
      <TreeHeader>
        <template #logo>
          <img src="@/assets//3d_icon/edit/lamplight_logo.png" alt="" />
        </template>
        <template #name>
          <span>场景灯光</span>
        </template>
      </TreeHeader>
      <ul class="cj_ul">
        <li class="cj_li" v-for="item in editLamplight" :key="item.id">
          <img class="item_pic" :src="item.img" alt="" />
          <span class="item_name">{{ item.name }}</span>
        </li>
      </ul>

      <!-- 场景背景------------------------- -->
      <TreeHeader>
        <template #logo>
          <img src="@/assets//3d_icon/edit/mapbg_logo.png" alt="" />
        </template>
        <template #name>
          <span>场景背景</span>
        </template>
        <template #icon>
          <img src="@/assets//3d_icon/add-icon.png" alt="" />
        </template>
      </TreeHeader>
      <ul class="bj_ul">
        <li class="bj_li" v-for="item in mapList" :key="item.id+'map'">
          <img :src="item.img" alt="" />
          <span class="bj_name">{{ item.name }}</span>
        </li>
      </ul>
    </div>
    <!-------------------------------------- 数据绑定------------------------ -->
    <div class="right" v-if="isActive == 2">
      <!-- 设备数据绑定------------------------- -->
      <TreeHeader>
        <template #logo>
          <img
            v-if="isArrow1"
            class="arrow1"
            @click="isArrow1 = false"
            src="@/assets//3d_icon/bind//arrow-down.png"
            alt=""
          />
          <img
            v-else
            class="arrow2"
            @click="isArrow1 = true"
            src="@/assets//3d_icon/bind/arrow-right.png"
            alt=""
          />
        </template>
        <template #name>
          <span>设备数据绑定</span>
        </template>
        <template #icon>
          <img src="@/assets/3d_icon//bind//camera.png" alt="" />
        </template>
        <template #btn>
          <a-switch class="switch" size="small" :checked="isChecked1" @click="toChange" />
        </template>
      </TreeHeader>
      <ul class="bind_ul" v-show="isArrow1">
        <li class="bind_li" v-for="item in bindList" :key="item.id">
          <div class="water_lf">
            <img :src="item.img" alt="" />
          </div>
          <div class="water_rg">
            <div class="water_box">
              <span class="bind_title">#{{ item.title }}</span>
              <input type="number" min="0" v-model="item.num" alt="" />
              <div class="input_box">
                <!-- 加 -->
                <a-icon
                  @click="item.num++"
                  type="caret-up"
                  style="color: rgba(255, 255, 255, 1)"
                />
                <!-- 减 -->
                <a-icon
                  @click="item.num--"
                  type="caret-down"
                  style="color: rgba(255, 255, 255, 1)"
                />
              </div>
            </div>
            <div class="water_box work">
              <img
                class="work_pic"
                src="@/assets//3d_icon/bind/work.png"
                alt=""
              />
              <span class="bind_type">类型：</span>
              <span class="bind_type">{{ item.type }}</span>
            </div>
            <div class="water_box iconbox">
              <div class="water_icon">
                <img src="@/assets//3d_icon/bind/edit_icon.png" alt="" />
              </div>
              <div class="water_icon">
                <img src="@/assets//3d_icon/bind/toggle.png" alt="" />
              </div>
              <div class="water_icon">
                <img src="@/assets//3d_icon/bind/eyes.png" alt="" />
              </div>
              <div class="water_icon">
                <img src="@/assets//3d_icon/bind/del.png" alt="" />
              </div>
            </div>
          </div>
        </li>
      </ul>

      <!-- 状态逻辑绑定------------------------- -->
      <TreeHeader>
        <template #logo>
          <img
            v-if="isArrow2"
            class="arrow1"
            @click="isArrow2 = false"
            src="@/assets//3d_icon/bind//arrow-down.png"
            alt=""
          />
          <img
            v-else
            class="arrow2"
            @click="isArrow2 = true"
            src="@/assets//3d_icon/bind/arrow-right.png"
            alt=""
          />
        </template>
        <template #name>
          <span>状态逻辑绑定</span>
        </template>
        <template #icon>
          <img src="@/assets/3d_icon/add-icon.png" alt="" />
        </template>
      </TreeHeader>
      <ul class="bind_ul" v-show="isArrow2">
        <li class="bind_li" v-for="item in stateList" :key="item.id">
          <div class="water_lf">
            <img :src="item.img" alt="" />
          </div>
          <div class="water_rg">
            <div class="water_box">
              <span class="bind_title">#{{ item.title }}</span>
            </div>
            <div class="water_box state">
              <span class="bind_type">正常：</span>
              <img class="lem" src="@/assets/3d_icon/bind/lem_a.png" alt="" />
              <span class="bind_type">异常：</span>
              <img class="lem" src="@/assets/3d_icon/bind/lem_b.png" alt="" />
            </div>
            <div class="water_box iconbox">
              <div class="water_icon">
                <img src="@/assets//3d_icon/bind/edit_icon.png" alt="" />
              </div>
              <div class="water_icon">
                <img src="@/assets//3d_icon/bind/del.png" alt="" />
              </div>
            </div>
          </div>
        </li>
      </ul>

      <!-- 图标绑定------------------------- -->
      <TreeHeader>
        <template #logo>
          <img
            v-if="isArrow3"
            class="arrow1"
            @click="isArrow3 = false"
            src="@/assets//3d_icon/bind//arrow-down.png"
            alt=""
          />
          <img
            v-else
            class="arrow2"
            @click="isArrow3 = true"
            src="@/assets//3d_icon/bind/arrow-right.png"
            alt=""
          />
        </template>
        <template #name>
          <span>图标绑定</span>
        </template>
        <template #btn>
          <a-switch class="switch" size="small" :checked="isChecked2" @click="toChangeIcon" />
        </template>
      </TreeHeader>
    </div>
  </div>
</template>
<script>
import TreeHeader from "./comm/treeHeader.vue";
export default {
  components: {
    TreeHeader
  },
  data() {
    return {
      isActive: 1,
      isArrow1: true,
      isArrow2: true,
      isArrow3: true,
      isChecked1: false,
      isChecked2: false,
      editLamplight: [
        {
          id: 1,
          name: "灯光源",
          img: require("@/assets/3d_icon/edit/lamp_1.png"),
        },
        {
          id: 2,
          name: "平行光",
          img: require("@/assets/3d_icon/edit/lamp_2.png"),
        },
        {
          id: 3,
          name: "半球光",
          img: require("@/assets/3d_icon/edit/lamp_3.png"),
        },
        {
          id: 4,
          name: "环境光",
          img: require("@/assets/3d_icon/edit/lamp_4.png"),
        },
        {
          id: 5,
          name: "区域光",
          img: require("@/assets/3d_icon/edit/lamp_5.png"),
        },
        {
          id: 6,
          name: "聚光灯",
          img: require("@/assets/3d_icon/edit/lamp_5.png"),
        },
      ],
      mapList: [
        {
          id: 1,
          name: "透明",
          img: require("@/assets/3d_icon/edit/mapbg_1.png"),
        },
        {
          id: 2,
          name: "白天",
          img: require("@/assets/3d_icon/edit/mapbg_2.png"),
        },
        {
          id: 3,
          name: "傍晚",
          img: require("@/assets/3d_icon/edit/mapbg_3.png"),
        },
        {
          id: 4,
          name: "晚上",
          img: require("@/assets/3d_icon/edit/mapbg_4.png"),
        },
      ],
      bindList: [
        {
          id: 1,
          title: "提水泵数据",
          type: "水泵",
          img: require("@/assets/3d_icon/bind/water1.png"),
          num: 5,
        },
        {
          id: 1,
          title: "提水泵数据",
          type: "水泵",
          img: require("@/assets/3d_icon/bind/water2.png"),
          num: 3,
        },
      ],
      stateList: [
        {
          id: 1,
          title: "提水泵数据",
          img: require("@/assets/3d_icon/bind/water1.png"),
        },
        {
          id: 1,
          title: "提水泵数据",
          img: require("@/assets/3d_icon/bind/water2.png"),
        },
      ],
    };
  },
  created() {
    this.$bus.$on("changeId", (val) => {
      // console.log("val===",val);
      this.isActive = val;
    });
  },
  methods: {
    // 改变状态(图标)
    toChangeIcon(e){
      this.isChecked2 = e;
    },
    // 改变状态
    toChange(e) {
      // console.log("e==",e);
      this.isChecked1 = e;
    },
  },
};
</script>
<style lang="scss" scoped>
.panel {
  flex: 1;
  color: #fff;
  display: flex;
  font-family: Source Han Sans CN;
  list-style: none;
  .left,
  .right {
    width: 100%;
    background-color: #202735;
  }
  .cj_ul {
    display: flex;
    padding-left: 23px;
    flex-wrap: wrap;
    .cj_li {
      list-style: none;
      width: 87px;
      height: 80px;
      margin-right: 18px;
      margin-top: 20px;
      background-color: #252d3b;
      border-radius: 4px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      .item_pic {
        width: 27px;
        height: 28px;
      }
      .item_name {
        margin-top: 9px;
        font-size: 14px;
        font-weight: 300;
        color: #ffffff;
        opacity: 0.8;
      }
    }
  }
  .bj_ul {
    display: flex;
    flex-wrap: wrap;
    .bj_li {
      width: 138px;
      height: 80px;
      margin-top: 20px;
      margin-left: 21px;
      position: relative;
      img {
        width: 100%;
        height: 100%;
      }
      .bj_name {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        font-size: 14px;
        color: #fff;
        font-weight: 500;
      }
    }
  }
  .bind_ul {
    .bind_li {
      margin: 0 auto;
      margin-top: 10px;
      width: 320px;
      height: 132px;
      background: #2b3240;
      display: flex;
      box-sizing: border-box;
      padding: 14px;
      .water_lf {
        width: 104px;
        height: 104px;
        border-radius: 4px;
        background-color: #fff;
        margin-right: 9px;
        overflow: hidden;
        img {
          width: 100%;
          height: 100%;
        }
      }
      .water_rg {
        flex: 1;
        display: flex;
        // background-color: #48e283;
        flex-direction: column;
        justify-content: space-between;
        .water_box {
          height: 28px;
          display: flex;
          justify-content: space-between;
          align-items: center;
          // background-color: #fff;
          position: relative;
          .lem {
            width: 19px;
            height: 19px;
            margin-right: 10px;
          }
          span {
            color: #fff;
          }
          input {
            width: 56px;
            height: 28px;
            outline: none;
            background-color: #222b38;
            border: 1px solid #454c57;
            border-radius: 2px;
            // text-align: center;
            padding-left: 12px;
            color: #fff;
            -moz-appearance: textfield;
            &::-webkit-inner-spin-button,
            &::-webkit-outer-spin-button {
              -webkit-appearance: none;
              margin: 0;
            }
          }
          .input_box {
            position: absolute;
            top: 0.5px;
            right: 1px;
            width: 20px;
            height: 27px;
            background: #39414c;
            border-radius: 0px 2px 2px 0px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            ::v-deep .anticon {
              margin: -2px;
            }
          }

          input .work_pic {
            width: 19px;
            height: 17px;
          }
          .water_icon {
            width: 28px;
            height: 28px;
            background: #3b424f;
            border-radius: 2px;
            padding: 4px;
            margin-right: 10px;
            box-sizing: border-box;
            img {
              width: 90%;
              height: 85%;
            }
          }
        }
        .work {
          justify-content: start;
          align-items: center;
          img {
            width: 19px;
            height: 17px;
          }
          .bind_type {
            margin-left: 5px;
          }
        }
        .state {
          justify-content: start;
        }
        .iconbox {
          // flex-direction: column;
          justify-content: start;
        }
      }
    }
  }
  ::v-deep .ant-switch {
    background-color: #48e283;
  }
  ::v-deep .ant-switch-checked {
    background-color: #1890ff;
  }
}
</style>
